package com.example.exception;

import com.example.common.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

//定义全局处理异常类
@RestControllerAdvice
public class ProjectExpectionAdvice {
    //处理自定义的ServiceExpection异常
    @ExceptionHandler(ServiceExpection.class)
    public Result doServiceExpection(ServiceExpection ex){
//        将结果返回给前端
        return Result.error(ex.getCode(),ex.getMessage());
    }
}
